package com.wx.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wx.pojo.User;
import com.wx.pojo.vo.JsonResult;
import com.wx.service.UserService;

@RestController
@RequestMapping("/user/")
public class UserController {

	@Autowired
	UserService userService;

	@RequestMapping("login")
	public JsonResult login(String userName,String pwd) {
		return new JsonResult(userService.login(userName, pwd));
	}

	@RequestMapping("register")
	public JsonResult addUser(User user) {
		return new JsonResult(userService.saveUser(user));
	}
	
	/**
	 * 给一个默认用户   注： 用户名不能重复    
	 * @return
	 */
	@RequestMapping("defaultAdd")
	public JsonResult adfaultAdd() {
		User user = new User();
		user.setUserName("wjx");
		user.setUserTel("18508341314");
		user.setUserPwd("123456");
		user.setSex("男");
		user.setAvater("http://img5.imgtn.bdimg.com/it/u=3768890033,68770272&fm=26&gp=0.jpg");
		user.setAddress("四川省-凉山州-西昌市-月化乡");
		user.setWechatQrCode("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559886612657&di=71cb8920646fda3841e51e91fa116721&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F01%2F48%2F34%2F7657442144c5df2.jpg");
		user.setPubQrCode("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559886612657&di=720afea34c77e82689c6035074c2499a&imgtype=0&src=http%3A%2F%2Fphotocdn.sohu.com%2F20150822%2FImg419472540.jpg");
		userService.saveUser(user);
		return new JsonResult("默认用户添加成功");
	}

}
